package cn.cdutetc.foxwatch.pojo;


import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

//统一响应结果
@Data
@NoArgsConstructor
@Schema(name = "Result", description = "统一响应结果")
<<<<<<< HEAD
public class Result<T> {
=======
public class Result<T> implements Serializable {
>>>>>>> f0dd41dd48d79067fa2de22e427243c250479df2
    @Schema(description = "业务状态码  0-成功  1-失败")
    private Integer code;
    @Schema(description = "提示信息")
    private String message;
    @Schema(description = "响应数据")
    private T data;//响应数据

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }


    //快速返回操作成功响应结果(带响应数据)
    public static <T> Result<T> success(T data) {
        return new Result<>(0, "操作成功", data);
    }

    //快速返回操作成功响应结果
    public static <T> Result<T> success() {
        return new Result<>(0, "操作成功", null);
    }

    public static <T> Result<T> success(String message, T data) {
        return new Result<>(0, message, data);
<<<<<<< HEAD
=======
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(1, message, null);
>>>>>>> f0dd41dd48d79067fa2de22e427243c250479df2
    }

    public static <T> Result<T> error(String message) {
        return new Result<>(1, message, null);
    }

   
}
